package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.AppNoticeMessage;
import com.ruoyi.system.domain.vo.AppNoticeMessageSearchVo;
import com.ruoyi.system.domain.vo.AppNoticeMessageVo;
import com.ruoyi.system.domain.vo.MemberPackageVo;
import com.ruoyi.system.domain.vo.MemberSearchVo;
import com.ruoyi.system.dto.AppNoticeMessageDTO;
import com.ruoyi.system.dto.MemberPackageDTO;
import com.ruoyi.system.service.IAppNoticeMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/notice")
@Api(tags = "app消息公告")
public class AppNoticeMessageController extends BaseController {
    @Autowired
    private IAppNoticeMessageService service;

    /**
     * 新增或编辑消息公告
     */
    @ApiOperation(value = "新增或编辑消息公告")
    @PostMapping(value = "/addOrUpdate")
    public AjaxResult addOrUpdate(@RequestBody AppNoticeMessageVo vo)
    {
        return success(service.addOrUpdate(vo));
    }

    /**
     * 消息公告列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AppNoticeMessageSearchVo searchVo)
    {
        startPage();
        List<AppNoticeMessageDTO> dto =  service.getList(searchVo);
        // 获取准确的总数
        int total = service.countList(searchVo);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(200);
        rspData.setMsg("查询成功");
        rspData.setRows(dto);
        rspData.setTotal(total);
        return rspData;
    }

    /**
     * 消息公告列表详情
     */
    @GetMapping("/info/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return success(service.getInfo(id));
    }


    /**
     * 消息公告列表详情
     */
    @GetMapping("/del/{id}")
    public AjaxResult del(@PathVariable Long id)
    {
        return success(service.del(id));
    }



}
